home *** CD-ROM | disk | FTP | other *** search
- #ifndef __STD_IOS__
- #define __STD_IOS__
- #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
-
- /***************************************************************************
- *
- * ios - Declarations for the Standard Library basic stream I/O
- *
- * $Id: ios,v 1.94 1996/09/24 19:17:05 smithey Exp $
- *
- ***************************************************************************
- *
- * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
- * ALL RIGHTS RESERVED *
- * The software and information contained herein are proprietary to, and
- * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
- * intends to preserve as trade secrets such software and information.
- * This software is furnished pursuant to a written license agreement and
- * may be used, copied, transmitted, and stored only in accordance with
- * the terms of such license and with the inclusion of the above copyright
- * notice. This software and information or any other copies thereof may
- * not be provided or otherwise made available to any other person.
- *
- * Notwithstanding any other lease or license that may pertain to, or
- * accompany the delivery of, this computer software and information, the
- * rights of the Government regarding its use, reproduction and disclosure
- * are as set forth in Section 52.227-19 of the FARS Computer
- * Software-Restricted Rights clause.
- *
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 252.227-7013.
- * Contractor/Manufacturer is Rogue Wave Software, Inc.,
- * P.O. Box 2328, Corvallis, Oregon 97339.
- *
- * This computer software and information is distributed with "restricted
- * rights." Use, duplication or disclosure is subject to restrictions as
- * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
- * Computer Software-Restricted Rights (April 1985)." If the Clause at
- * 18-52.227-74 "Rights in Data General" is specified in the contract,
- * then the "Alternate III" clause applies.
- *
- **************************************************************************/
-
- #ifndef __STD_RWCOMPILER_H__
- #include <stdcomp.h>
- #endif
-
- // Get the locale class
- #include <rw/rwlocale>
-
- // Get the facets
- #include <rw/ctype>
- #include <rw/codecvt>
- #include <rw/numeral>
-
- // Get declarations for the standard xxx_byname facets and for vendor-defined
- // extensions, such as declarations of the facets of the native ("") locale.
- #include <rw/vendor>
-
- // Get usefacet and hasfacet
- #include <rw/usefacet>
-
-
- #ifndef _RWSTD_NO_NAMESPACE
- namespace __rwstd {
- #endif
-
- extern const char _RWSTDExportFunc(*) rwse_failbit_set;
- extern const char _RWSTDExportFunc(*) rwse_badbit_set;
- extern const char _RWSTDExportFunc(*) rwse_eofbit_set;
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- namespace std {
- #endif
-
- /*
- *
- * CLASS BASIC_IOS
- *
- */
-
- template<class charT, class traits>
- class _RWSTDExportTemplate basic_ios : public ios_base {
-
- public:
-
- typedef basic_ios<charT, traits> ios_type;
- typedef basic_streambuf<charT, traits> streambuf_type;
- typedef basic_ostream<charT, traits> ostream_type;
-
- // simplification
- typedef _TYPENAME traits::char_type char_type;
- typedef traits traits_type;
-
- typedef _TYPENAME traits::int_type int_type;
- typedef _TYPENAME traits::off_type off_type;
- typedef _TYPENAME traits::pos_type pos_type;
-
-
- _EXPLICIT basic_ios(basic_streambuf<charT, traits> *sb_arg);
- virtual ~basic_ios();
-
- char_type fill() const;
- char_type fill(char_type ch);
-
- inline void exceptions(iostate excpt);
- inline iostate exceptions() const;
-
- inline void clear(iostate state = goodbit);
-
- inline void setstate(iostate state);
- inline iostate rdstate() const;
-
- inline operator void*() const;
- inline bool operator! () const;
-
- inline bool good() const;
- inline bool eof() const;
- inline bool fail() const;
- inline bool bad() const;
-
- ios_type& copyfmt(const ios_type& rhs);
-
- inline ostream_type *tie() const;
- ostream_type *tie(ostream_type *tie_arg);
-
- inline streambuf_type *rdbuf() const;
- streambuf_type *rdbuf( streambuf_type *sb);
-
- locale imbue(const locale& loc);
-
- inline char narrow(charT, char) const;
- inline charT widen(char) const;
-
- protected:
-
- basic_ios();
-
- void init(basic_streambuf<charT, traits> *sb);
-
- inline void _RW_UNSAFE_clear(iostate state = goodbit);
-
- private:
-
- streambuf_type *sb_;
-
- ostream_type *tiestr_;
-
- char_type fillch_;
-
- iostate state_;
- iostate except_;
-
- };
-
-
- /*
- *
- * INLINE DEFINITIONS
- *
- */
-
-
- /*
- * basic_streambuf *rdbuf() const
- */
-
- template<class charT, class traits>
- inline basic_streambuf<charT, traits> *
- basic_ios<charT, traits>::rdbuf() const
- {
- return sb_;
- }
-
- /*
- * basic_ostream *tie() const
- */
-
- template<class charT, class traits>
- inline basic_ostream<charT, traits> *
- basic_ios<charT, traits>::tie() const
- {
- return tiestr_;
- }
-
-
- /*
- * void exceptions(iostate)
- */
-
- template<class charT, class traits>
- inline void
- basic_ios<charT, traits>::exceptions(ios_base::iostate st)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- except_ = st;
-
- #ifdef _RWSTD_MULTI_THREAD
- _RW_UNSAFE_clear(rdstate());
- #else
- clear(rdstate());
- #endif
- }
-
- /*
- * iostate exceptions() const
- */
-
- template<class charT, class traits>
- inline ios_base::iostate
- basic_ios<charT, traits>::exceptions() const
- {
- return except_;
- }
-
-
- /*
- * void clear(iostate )
- */
-
- template<class charT, class traits>
- inline void
- basic_ios<charT, traits>::clear(iostate st)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- _RW_UNSAFE_clear(st);
-
- }
-
- /*
- * void setstate(iostate)
- */
-
- template<class charT, class traits>
- inline void
- basic_ios<charT, traits>::setstate(iostate st)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- #ifdef _RWSTD_MULTI_THREAD
- _RW_UNSAFE_clear(state_ | st);
- #else
- clear(state_ | st);
- #endif
- }
-
- /*
- * iostate rdstate() const
- */
-
- template<class charT, class traits>
- inline ios_base::iostate
- basic_ios<charT, traits>::rdstate() const
- {
- return state_;
- }
-
- /*
- * operator bool() const
- */
-
- template<class charT, class traits>
- inline basic_ios<charT, traits>::operator void*() const
- {
- return fail() ? (void*)0 : (void*)1;
- }
-
- /*
- * bool operator!() const
- */
-
- template<class charT, class traits>
- inline bool
- basic_ios<charT, traits>::operator!() const
- {
- return fail();
- }
-
- /*
- * bool good() const
- */
-
- template<class charT, class traits>
- inline bool
- basic_ios<charT, traits>::good() const
- {
- return (state_ == ios_base::goodbit);
- }
-
- /*
- * bool eof() const
- */
-
- template<class charT, class traits>
- inline bool
- basic_ios<charT, traits>::eof() const
- {
- return (state_ & ios_base::eofbit);
- }
-
- /*
- * bool fail() const
- */
-
- template<class charT, class traits>
- inline bool
- basic_ios<charT, traits>::fail() const
- {
- return (state_ & (ios_base::failbit | ios_base::badbit));
- }
-
- /*
- * bool bad() const
- */
-
- template<class charT, class traits>
- inline bool
- basic_ios<charT, traits>::bad() const
- {
- return (state_ & ios_base::badbit);
- }
-
- /*
- * void _RW_UNSAFE_clear(iostate )
- */
-
- template<class charT, class traits>
- inline void
- basic_ios<charT, traits>::_RW_UNSAFE_clear(iostate st)
- {
- if ( !sb_ )
- {
- st |= ios_base::badbit;
- state_ |= ios_base::badbit;
- }
-
- state_ = st;
-
- if( rdstate() & exceptions() )
- {
- #ifdef _RW_STD_EXCEPT
- #ifndef _RWSTD_NO_EXCEPTIONS
- if ( rdstate() & exceptions() & ios_base::failbit )
- {
- state_=st;
- throw ios_base::failure( string(__RWSTD::rwse_failbit_set) );
- }
-
- if ( rdstate() & exceptions() & ios_base::badbit )
- {
- state_=st;
- throw ios_base::failure( string(__RWSTD::rwse_badbit_set) );
- }
- if ( rdstate() & exceptions() & ios_base::eofbit )
- {
- state_=st;
- throw ios_base::failure( string(__RWSTD::rwse_eofbit_set) );
- }
- #endif
- #endif
- }
- }
-
- /*
- * char narrow(charT, char) const
- */
-
- template<class charT, class traits>
- inline char
- basic_ios<charT, traits>::narrow(charT c, char dfault) const
- {
- #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
- return use_facet< ctype<charT> >(getloc()).narrow(c.dfault);
- #else
- return use_facet(getloc(),(ctype<charT>*)0).narrow(c,dfault);
- #endif
-
- }
-
- /*
- * charT widen(char) const
- */
-
- template<class charT, class traits>
- inline charT
- basic_ios<charT, traits>::widen(char c) const
- {
- #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
- return use_facet< ctype<charT> >(getloc()).widen(c);
- #else
- return use_facet(getloc(),(ctype<charT>*)0).widen(c);
- #endif
-
- }
-
-
- // end inlining
-
-
- #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
- typedef basic_ios<char> ios;
- #else
- typedef basic_ios<char, char_traits<char> > ios;
- #endif
-
- #ifndef _RWSTD_NO_WIDE_CHAR
- #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
- typedef basic_ios<wchar_t> wios;
- #else
- typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
- #endif
- #endif
-
- /*
- *
- * EXTERNAL DECLARATIONS FOR MANIPULATORS
- *
- */
-
-
- #ifdef _RWSTD_MULTI_THREAD
- template <class charT, class traits>
- basic_ios<charT,traits>& lock(basic_ios<charT,traits>&);
-
- template <class charT, class traits>
- basic_ios<charT,traits>& unlock(basic_ios<charT,traits>&);
- #endif
-
-
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- #endif
-
- #ifdef _RWSTD_COMPILE_INSTANTIATE
- #include <ios.cc>
- #endif
-
- #ifndef __USE_STD_NAMES__
- using namespace std;
- #endif
-
- #pragma option pop
- #endif /* __STD_IOS__ */
-